<template>
  <div class="person-center-wrap">
    <div class="person-center-tab-list">
      <p
        @click="checkTap(item, index)"
        :class="{ active: acTab == index }"
        v-for="(item, index) in translatedtabList"
        :key="index"
        v-show="!(isPutong && index == 1) && !(!isExpert && index == 3)"
      >
        {{ item.name }}
      </p>
    </div>
    <Info v-if="acTab == 0"></Info>
    <faList v-if="acTab == 2"></faList>
    <jieList v-if="acTab == 3"></jieList>
    <myAccount v-if="acTab == 1"></myAccount>
  </div>
</template>
<script>
import Info from "./component/info.vue";
import faList from "./component/faList.vue";
import myAccount from "./component/myAccount.vue";
import jieList from "./component/jieList.vue";
export default {
  data() {
    return {
      acTab: 0,
      tabList: [
        {
          id: 1,
          name: "个人资料",
        },
        {
          id: 2,
          name: "我的账户",
        },
        {
          id: 3,
          name: "我的发单",
        },
        {
          id: 4,
          name: "我的接单",
        },
      ],
    };
  },
  computed: {
    translatedtabList() {
      return this.tabList.map((item) => ({
        ...item,
        name: this.$t(item.name),
      }));
    },
    isPutong() {
      return this.$store.getters.isPutong;
    },
    isExpert() {
      return this.$store.getters.isExpert;
    },
  },
  components: {
    Info,
    faList,
    jieList,
    myAccount,
  },
  mounted() {
    this.acTab = this.$store.state.personTab;
  },
  // beforeRouteEnter(to, from, next) {
  //   next((vm) => {
  //     if (from.name == "Authbind") {
  //       vm.
  //     }
  //   });
  // },
  methods: {
    checkTap(item, index) {
      this.acTab = index;
      this.$store.commit("SET_PERSONTAB", index);
    },
  },
};
</script>
<style lang="scss" scoped>
.person-center-wrap {
  width: 64.39rem;
  background: #f5f7fa;
  border-radius: 0.44rem;
  margin: 3.72rem auto 5.61rem 7.78rem;
  .person-center-tab-list {
    display: flex;
    height: 3.11rem;
    line-height: 3.11rem;
    font-size: 0.78rem;
    color: #666666;
    p {
      padding: 0 1.33rem;
      cursor: pointer;
      &.active {
        color: #146eb4;
        font-weight: bold;
        border-bottom: 0.11rem solid #146eb4;
      }
    }
  }
}
</style>
